home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / gl_dev.idb / usr / share / src / OpenGL / toolkits / libglut / glutint.h.z / glutint.h
Encoding:
C/C++ Source or Header  |  1996-12-06  |  14.6 KB  |  377 lines

  1. #ifndef __glutint_h__
  2. #define __glutint_h__
  3.  
  4. /* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */
  5.  
  6. /* This program is freely distributable without licensing fees 
  7.    and is provided without guarantee or warrantee expressed or 
  8.    implied. This program is -not- in the public domain. */
  9.  
  10. #ifdef __sgi
  11. #define SUPPORT_FORTRAN
  12. #endif
  13. #include <X11/Xlib.h>
  14. #include <GL/glx.h>
  15. #include <GL/glut.h>
  16. #include <sys/types.h>
  17. #include <sys/time.h>
  18. #ifdef SVR4
  19. #define GETTIMEOFDAY(_x) gettimeofday(_x)
  20. #else
  21. #define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
  22. #endif
  23. #define ADD_TIME(dest, src1, src2) { \
  24.   if(((dest).tv_usec = \
  25.     (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
  26.     (dest).tv_usec -= 1000000; \
  27.     (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
  28.   } else { \
  29.     (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
  30.     if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
  31.       (dest).tv_sec --;(dest).tv_usec += 1000000; \
  32.     } \
  33.   } \
  34. }
  35. #define TIMEDELTA(dest, src1, src2) { \
  36.   if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
  37.     (dest).tv_usec += 1000000; \
  38.     (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
  39.   } else { \
  40.      (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
  41.   } \
  42. }
  43. #define IS_AFTER(t1, t2) \
  44.   (((t2).tv_sec > (t1).tv_sec) || \
  45.   (((t2).tv_sec == (t1).tv_sec) && \
  46.   ((t2).tv_usec > (t1).tv_usec)))
  47. #define IS_AT_OR_AFTER(t1, t2) \
  48.   (((t2).tv_sec > (t1).tv_sec) || \
  49.   (((t2).tv_sec == (t1).tv_sec) && \
  50.   ((t2).tv_usec >= (t1).tv_usec)))
  51. #define GLUT_WIND_IS_RGB(x)         (((x) & GLUT_INDEX) == 0)
  52. #define GLUT_WIND_IS_INDEX(x)       (((x) & GLUT_INDEX) != 0)
  53. #define GLUT_WIND_IS_SINGLE(x)      (((x) & GLUT_DOUBLE) == 0)
  54. #define GLUT_WIND_IS_DOUBLE(x)      (((x) & GLUT_DOUBLE) != 0)
  55. #define GLUT_WIND_HAS_ACCUM(x)      (((x) & GLUT_ACCUM) != 0)
  56. #define GLUT_WIND_HAS_ALPHA(x)      (((x) & GLUT_ALPHA) != 0)
  57. #define GLUT_WIND_HAS_DEPTH(x)      (((x) & GLUT_DEPTH) != 0)
  58. #define GLUT_WIND_HAS_STENCIL(x)    (((x) & GLUT_STENCIL) != 0)
  59. #if (GLUT_API_VERSION >= 2)
  60. #define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
  61. #define GLUT_WIND_IS_STEREO(x)      (((x) & GLUT_STEREO) != 0)
  62. #endif
  63. #define GLUT_MAP_WORK               (1 << 0)
  64. #define GLUT_EVENT_MASK_WORK        (1 << 1)
  65. #define GLUT_REDISPLAY_WORK         (1 << 2)
  66. #define GLUT_CONFIGURE_WORK         (1 << 3)
  67. #define GLUT_COLORMAP_WORK          (1 << 4)
  68. #define GLUT_DEVICE_MASK_WORK        (1 << 5)
  69. #define GLUT_FINISH_WORK        (1 << 6)
  70. #define GLUT_DEBUG_WORK            (1 << 7)
  71. #define GLUT_DUMMY_WORK            (1 << 8)
  72. /* GLUT callback function types */
  73. typedef void (*GLUTdisplayCB) (void);
  74. typedef void (*GLUTreshapeCB) (int, int);
  75. typedef void (*GLUTkeyboardCB) (unsigned char, int, int);
  76. typedef void (*GLUTmouseCB) (int, int, int, int);
  77. typedef void (*GLUTmotionCB) (int, int);
  78. typedef void (*GLUTpassiveCB) (int, int);
  79. typedef void (*GLUTentryCB) (int);
  80. typedef void (*GLUTvisibilityCB) (int);
  81. typedef void (*GLUTidleCB) (void);
  82. typedef void (*GLUTtimerCB) (int);
  83. typedef void (*GLUTmenuStateCB) (int);  /* DEPRICATED. */
  84. typedef void (*GLUTmenuStatusCB) (int, int, int);
  85. typedef void (*GLUTselectCB) (int);
  86. #if (GLUT_API_VERSION >= 2)
  87. typedef void (*GLUTspecialCB) (int, int, int);
  88. typedef void (*GLUTspaceMotionCB) (int, int, int);
  89. typedef void (*GLUTspaceRotateCB) (int, int, int);
  90. typedef void (*GLUTspaceButtonCB) (int, int);
  91. typedef void (*GLUTdialsCB) (int, int);
  92. typedef void (*GLUTbuttonBoxCB) (int, int);
  93. typedef void (*GLUTtabletMotionCB) (int, int);
  94. typedef void (*GLUTtabletButtonCB) (int, int, int, int);
  95. #endif
  96.  
  97. #ifdef SUPPORT_FORTRAN
  98. typedef void (*GLUTdisplayFCB) (void);
  99. typedef void (*GLUTreshapeFCB) (int *, int *);
  100. /* NOTE the pressed key is int, not unsigned char for Fortran! */
  101. typedef void (*GLUTkeyboardFCB) (int *, int *, int *);
  102. typedef void (*GLUTmouseFCB) (int *, int *, int *, int *);
  103. typedef void (*GLUTmotionFCB) (int *, int *);
  104. typedef void (*GLUTpassiveFCB) (int *, int *);
  105. typedef void (*GLUTentryFCB) (int *);
  106. typedef void (*GLUTvisibilityFCB) (int *);
  107. typedef void (*GLUTidleFCB) (void);
  108. typedef void (*GLUTtimerFCB) (int *);
  109. typedef void (*GLUTmenuStateFCB) (int *);  /* DEPRICATED. */
  110. typedef void (*GLUTmenuStatusFCB) (int *, int *, int *);
  111. typedef void (*GLUTselectFCB) (int *);
  112. #if (GLUT_API_VERSION >= 2)
  113. typedef void (*GLUTspecialFCB) (int *, int *, int *);
  114. typedef void (*GLUTspaceMotionFCB) (int *, int *, int *);
  115. typedef void (*GLUTspaceRotateFCB) (int *, int *, int *);
  116. typedef void (*GLUTspaceButtonFCB) (int *, int *);
  117. typedef void (*GLUTdialsFCB) (int *, int *);
  118. typedef void (*GLUTbuttonBoxFCB) (int *, int *);
  119. typedef void (*GLUTtabletMotionFCB) (int *, int *);
  120. typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *);
  121. #endif
  122. #endif
  123. typedef struct _GLUTcolorcell GLUTcolorcell;
  124. struct _GLUTcolorcell {
  125.   /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
  126.   GLfloat component[3];
  127. };
  128. typedef struct _GLUTcolormap GLUTcolormap;
  129. struct _GLUTcolormap {
  130.   Visual *visual;       /* visual of the colormap */
  131.   Colormap cmap;        /* X colormap ID */
  132.   int refcnt;           /* number of windows using colormap */
  133.   int size;             /* number of cells in colormap */
  134.   GLUTcolorcell *cells; /* array of cells */
  135.   GLUTcolormap *next;   /* next colormap in list */
  136. };
  137. typedef struct _GLUTwindow GLUTwindow;
  138. struct _GLUTwindow {
  139.   int num;              /* small integer window id (0-based) */
  140.   /* Window system related state. */
  141.   Window win;           /* X window for glut window */
  142.   GLXContext ctx;       /* OpenGL context for glut window */
  143.   XVisualInfo *vis;     /* visual for window */
  144.   Colormap cmap;        /* RGB colormap for window; None if CI */
  145.   GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
  146.   /* GLUT settable or visible window state. */
  147.   int width;            /* window width in pixels */
  148.   int height;           /* window height in pixels */
  149.   Bool mapState;        /* map state */
  150.   int visState;         /* visibility state (-1 is unknown) */
  151. #define GLUT_MAX_MENUS              3
  152.  
  153.   int menu[GLUT_MAX_MENUS];  /* attatched menu nums */
  154.   /* Window relationship state. */
  155.   GLUTwindow *parent;   /* parent window */
  156.   GLUTwindow *children; /* list of children */
  157.   GLUTwindow *siblings; /* list of siblings */
  158.   /* Misc. non-API visible (hidden) state. */
  159.   Bool fakeSingle;      /* faking single buffer with double */
  160.   Bool forceReshape;    /* force reshape before display */
  161.   Bool isDirect;        /* if direct context */
  162.   long eventMask;       /* mask of X events selected for */
  163.   int buttonUses;       /* number of button uses, ref cnt */
  164. #if (GLUT_API_VERSION >= 2)
  165.   int tabletPos[2];     /* tablet position (-1 is invalid) */
  166. #endif
  167.   /* Work list related state. */
  168.   unsigned int workMask;  /* mask of window work to be done */
  169.   GLUTwindow *prevWorkWin;  /* link list of windows to work on */
  170.   Bool desiredMapState; /* how to mapped window if on map work
  171.                            list */
  172.   int desiredConfMask;  /* mask of desired window configuration 
  173.  
  174.                          */
  175.   int desiredX;         /* desired X location */
  176.   int desiredY;         /* desired Y location */
  177.   int desiredWidth;     /* desired window width */
  178.   int desiredHeight;    /* desired window height */
  179.   int desiredStack;     /* desired window stack */
  180.   /* Callbacks */
  181.   GLUTdisplayCB display;  /* redraw callback */
  182.   GLUTreshapeCB reshape;  /* resize callback (width,height) */
  183.   GLUTmouseCB mouse;    /* mouse callback (button,state,x,y) */
  184.   GLUTmotionCB motion;  /* motion callback (x,y) */
  185.   GLUTpassiveCB passive;  /* passive motion callback (x,y) */
  186.   GLUTentryCB entry;    /* window entry/exit callback (state) */
  187.   GLUTkeyboardCB keyboard;  /* keyboard callback (ASCII,x,y) */
  188.   GLUTvisibilityCB visibility;  /* visibility callback */
  189. #if (GLUT_API_VERSION >= 2)
  190.   GLUTspecialCB special;  /* special key callback */
  191.   GLUTbuttonBoxCB buttonBox;  /* button box callback */
  192.   GLUTdialsCB dials;    /* dials callback */
  193.   GLUTspaceMotionCB spaceMotion;  /* Spaceball motion callback */
  194.   GLUTspaceRotateCB spaceRotate;  /* Spaceball rotate callback */
  195.   GLUTspaceButtonCB spaceButton;  /* Spaceball button callback */
  196.   GLUTtabletMotionCB tabletMotion;  /* tablet motion callback */
  197.   GLUTtabletButtonCB tabletButton;  /* tablet button callback */
  198. #endif
  199. #ifdef SUPPORT_FORTRAN
  200.   /* Special Fortran display callback unneeded since no
  201.      parameters! */
  202.   GLUTreshapeFCB freshape;  /* Fortran reshape callback */
  203.   GLUTmouseFCB fmouse;  /* Fortran mouse callback */
  204.   GLUTmotionFCB fmotion;  /* Fortran motion callback */
  205.   GLUTpassiveFCB fpassive;  /* Fortran passive callback */
  206.   GLUTentryFCB fentry;  /* Fortran entry callback */
  207.   GLUTkeyboardFCB fkeyboard;  /* Fortran keyboard callback */
  208.   GLUTvisibilityFCB fvisibility;  /* Fortran visibility
  209.                                      callback */
  210. #if (GLUT_API_VERSION >= 2)
  211.   GLUTspecialFCB fspecial;  /* special key callback */
  212.   GLUTbuttonBoxFCB fbuttonBox;  /* button box callback */
  213.   GLUTdialsFCB fdials;  /* dials callback */
  214.   GLUTspaceMotionFCB fspaceMotion;  /* Spaceball motion
  215.                                        callback */
  216.   GLUTspaceRotateFCB fspaceRotate;  /* Spaceball rotate
  217.                                        callback */
  218.   GLUTspaceButtonFCB fspaceButton;  /* Spaceball button
  219.                                        callback */
  220.   GLUTtabletMotionFCB ftabletMotion;  /* tablet motion callback 
  221.  
  222.                                        */
  223.   GLUTtabletButtonFCB ftabletButton;  /* tablet button callback 
  224.  
  225.                                        */
  226. #endif
  227. #endif
  228. };
  229. typedef struct _GLUTmenu GLUTmenu;
  230. typedef struct _GLUTmenuItem GLUTmenuItem;
  231.  
  232. struct _GLUTmenu {
  233.   int id;               /* small integer menu id */
  234.   Window win;           /* X window for the menu */
  235.   int num;              /* number of entries */
  236.   int submenus;         /* number of submenu entries */
  237.   Bool managed;         /* are the InputOnly windows size
  238.                            validated? */
  239.   int pixwidth;         /* width of menu in pixels */
  240.   int pixheight;        /* height of menu in pixels */
  241.   GLUTselectCB select;  /* callback function of menu */
  242.   GLUTmenuItem *list;   /* list of menu entries */
  243.   GLUTmenuItem *highlighted;  /* pointer to highlighted menu
  244.                                  entry, NULL not highlighted */
  245.   GLUTmenu *cascade;    /* currently cascading this menu  */
  246.   GLUTmenuItem *anchor; /* currently anchored to this entry */
  247.   int x;                /* current x origin relative to the
  248.                            root window */
  249.   int y;                /* current y origin relative to the
  250.                            root window */
  251. #ifdef SUPPORT_FORTRAN
  252.   GLUTselectFCB fselect;  /* callback function of menu */
  253. #endif
  254. };
  255.  
  256. struct _GLUTmenuItem {
  257.   Window win;           /* InputOnly X window for entry */
  258.   char *label;          /* strdup'ed label string */
  259.   int len;              /* length of label string */
  260.   int value;            /* value to return for selecting this
  261.                            entry; doubles as submenu id
  262.                            (0-base) if submenu trigger */
  263.   int pixwidth;         /* width of X window in pixels */
  264.   Bool isTrigger;       /* is a submenu trigger? */
  265.   GLUTmenu *menu;       /* menu entry belongs to */
  266.   GLUTmenuItem *next;   /* next menu entry on list for menu */
  267. };
  268.  
  269. typedef struct _GLUTtimer GLUTtimer;
  270. struct _GLUTtimer {
  271.   GLUTtimerCB func;     /* timer callback (value) */
  272.   struct timeval timeout;  /* time remaining */
  273.   int value;            /* callback return value */
  274.   GLUTtimer *next;      /* list of timers */
  275. #ifdef SUPPORT_FORTRAN
  276.   GLUTtimerFCB ffunc;   /* Fortran timer callback */
  277. #endif
  278. };
  279.  
  280. typedef struct _EventParser EventParser;
  281. struct _EventParser {
  282.   int (*func) (XEvent *);
  283.   EventParser *next;
  284. };
  285.  
  286. /* private variables from glut_event.c */
  287. extern GLUTwindow *__glutWindowWorkList;
  288. #ifdef SUPPORT_FORTRAN
  289. extern GLUTtimer *__glutTimerList;
  290. extern GLUTtimer *__glutNewTimer;
  291. #endif
  292. /* private variables from glut_init.c */
  293. extern Atom __glutWMDeleteWindow;
  294. extern Display *__glutDisplay;
  295. extern unsigned long __glutDisplayMode;
  296. extern GLboolean __glutDebug;
  297. extern GLboolean __glutForceDirect;
  298. extern GLboolean __glutIconic;
  299. extern GLboolean __glutTryDirect;
  300. extern Window __glutRoot;
  301. extern XSizeHints __glutSizeHints;
  302. extern char **__glutArgv;
  303. extern char *__glutProgramName;
  304. extern int __glutArgc;
  305. extern int __glutConnectionFD;
  306. extern int __glutInitHeight;
  307. extern int __glutInitWidth;
  308. extern int __glutInitX;
  309. extern int __glutInitY;
  310. extern int __glutScreen;
  311. extern int __glutScreenHeight;
  312. extern int __glutScreenWidth;
  313.  
  314. /* private variables from glut_menu.c */
  315. extern GLUTmenu *__glutCurrentMenu;
  316. extern GLUTmenuItem *__glutItemSelected;
  317. extern GLUTmenu *__glutMappedMenu;
  318. extern GLUTwindow *__glutMenuWindow;
  319. extern void (*__glutMenuStatusFunc) (int, int, int);
  320.  
  321. /* private variables from glut_win.c */
  322. extern GLUTwindow **__glutWindowList;
  323. extern GLUTwindow *__glutCurrentWindow;
  324. extern int __glutWindowListSize;
  325.  
  326. /* private routines from glut_cindex.c */
  327. extern GLUTcolormap *__glutAssociateColormap(XVisualInfo * vis);
  328. extern void __glutFreeColormap(GLUTcolormap *);
  329.  
  330. /* private routines from glut_event.c */
  331. extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
  332. extern void __glutPutOnWorkList(GLUTwindow * window,
  333.   int work_mask);
  334. extern void __glutRegisterEventParser(EventParser * parser);
  335.  
  336. /* private routines from glut_init.c */
  337. extern void __glutOpenXConnection(char *display);
  338. extern void __glutInitTime(struct timeval *beginning);
  339.  
  340. /* private routines for glut_menu.c */
  341. extern GLUTmenu *__glutGetMenu(Window win);
  342. extern GLUTmenu *__glutGetMenuByNum(int menunum);
  343. extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
  344.   Window win, int *which);
  345. extern void __glutFinishMenu(Window win, int x, int y);
  346. extern void __glutMenuItemEnterOrLeave(GLUTmenuItem * item,
  347.   int num, int type);
  348. extern void __glutPaintMenu(GLUTmenu * menu);
  349. extern void __glutSetMenu(GLUTmenu * menu);
  350. extern void __glutStartMenu(GLUTmenu * menu,
  351.   GLUTwindow * window, int x, int y, int x_win, int y_win);
  352.  
  353. /* private routines from glut_util.c */
  354. extern void __glutWarning(char *format,...);
  355. extern void __glutFatalError(char *format,...);
  356. extern void __glutFatalUsage(char *format,...);
  357.  
  358. /* private routines from glut_win.c */
  359. extern GLUTwindow *__glutGetWindow(Window win);
  360. extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
  361. extern void __glutChangeWindowEventMask(long mask, Bool add);
  362. extern void __glutEstablishColormapsProperty(
  363.   GLUTwindow * window);
  364. extern XVisualInfo *__glutGetVisualInfo(unsigned long mode);
  365. extern void __glutSetWindow(GLUTwindow * window);
  366. extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
  367.   int callingConvention);
  368. extern void __glutDefaultReshape(int, int);
  369.  
  370. /* private routines from glut_ext.c */
  371. extern int __glutIsSupportedByGLX(char *);
  372.  
  373. /* private routines from glut_input.c */
  374. extern void __glutUpdateInputDeviceMask(GLUTwindow * window);
  375.  
  376. #endif /* __glutint_h__ */
  377.